import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Lenovo
 */
public class HelloWorld {

    public static void main(String[] args) throws Throwable {
        HelloWorld helloWorld = new HelloWorld();
        helloWorld.stackLeakByThread();
        List<String> list = new ArrayList<>();
        int i = 0;
        while (true) {
            list.add(String.valueOf(i++).intern());
        }
//        Enhancer enhancer = new Enhancer();
//        enhancer.setSuperclass(HelloWorld.class);
//        enhancer.setUseCache(false);
//        enhancer.setCallback(new MethodInterceptor() {
//            @Override
//            public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
//                return proxy.invoke(obj, args);
//            }
//        });
//        enhancer.create();
//        enhancer.setCallback((MethodInterceptor) (obj, method, args1, proxy) -> proxy.invoke(obj, args1));

    }

    public void stackLeakByThread() {
        while (true) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    dontStop();
                }
            });
            thread.start();
        }
    }

    private void dontStop() {
        while (true) {
        }

    }
}


